<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="assetMenu" />
<meta name="nav" content="1" />
<meta name="acc" content="0" />
<base target="_self" />
<title>检测单位</title>
<!--  通用情况下 不引入 js css  表单验证  js 放置到页面中 -->
<script type="text/javascript"
	src="<c:url value='/ext/ui/jquery-ui-1.8.12.custom.min.js'/>"></script>
<link href="${ctx}/styles/lightness/jquery-ui-1.8.12.custom.css"
	rel="stylesheet" />
<script type='text/javascript'
	src='${ctx}/scripts/plugin/jquery.autocomplete.js'></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#beginDate").addClass("Wate").bind("click", function(){
   	 WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'});});
	 $("#endDate").addClass("Wate").bind("click", function(){
	 WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'});});
	 $("#orgCode").focus();
		
	 //单位名称和分支机构名称不可修改
	 var id = $("#id").val();
	 if(""==id||null==id){
		 $("#orgCode").attr("disabled",false);
		 $("#deptName").attr("disabled",false);
	 }
	 
	//单位名称自动补全 -->
	 
	 $("#orgName").autocomplete('${ctx}/project/sign/org/organization!signlist.action?typeId=4', {
			multiple: false,
			dataType: "json",
			minChars: 0,
			delay: 100,
			autoFill: false,
			parse: function(data) {
				return $.map(data, function(row) {
					return {
						data: row,
						value: row.orgId,
						result:  row.orgName 
					}
				});
			},
			formatItem: function(item) {
				return item.orgName ;
			}
		}).result(function(e, item) {
			if(item.orgName=="[ 新增 ]"){
					$("#orgName").val("");	
					var url;
					var typeId = item.typeId;
					var obj = new Object();
					if("2"==typeId){
						url = "${ctx}/project/org/designorg!input.action?typeId="+typeId;
					}else if("3"==typeId){
						url="${ctx}/project/org/supervisoryorg!input.action?typeId="+typeId;	
					}else if("4"==typeId){
						url="${ctx}/project/org/constructorg!input.action?typeId="+typeId;	
					}	
					    mm =showDialogWindow(url);
						if(mm){
							if(mm.orgName){
								$("#orgName").val(mm.orgName);
							}
							if(mm.orgId){
								$("#orgCode").val(mm.orgId);
							}
						}
			 }else{
				 $("#orgName").val(item.orgName);
			     $("#orgCode").val(item.orgId);
			 }
		});
	 $("#deptName").click(function(){
		    var orgName = $("#orgName").val();
			var orgCode = $("#orgCOde").val();
		 	if(confirm("是否创建部门!")){
				var url ="${ctx}/project/sign/org/department!input.action?organizationId="+orgCode;
				var obj = new Object();
				mm = showDialogWindow(url);
				if(mm){
					if(mm.depName)
						$("#deptName").val(mm.depName);
					if(mm.deptId)
						$("#branchOrgId").val(mm.deptId);
				}
			}else{
				var orgName = $("#orgName").val();
				var orgCode = $("#orgCode").val();
				$("#deptName").val(orgName);
				$("#orgId").val(orgCode);
				$("#mark").val("0");
			}
			
	 });
	 $("#inputForm").validate({
   			rules:{
   				orgName:{
   					required:true
   				},
   				orgCode:{
					required:true
				},
				contractOrder:{
   					required:true
   				},
   				contractNum:{
   					required:true
   				},
   				deptName:{
   					required:true
   				},
   	   			contractCost:{
	   	   			required:true,
					number:true
   	   			}
   			},
   			messages:{
   				orgCode:{
					required:"请选择有效的单位信息!"
				},
   			}
	});
});
function deletedesign(url){
	location.href=url;
}
</script>
</head>
<body>
<form action="${ctx}/project/sign/supervisory!save.action" method="post" id="inputForm"
	class='yform'>
<div id="tabs">
<h1>增加检测合同信息</h1>
<table width="200" class="noborder">

	<tr>
		<td>单位名称：</td>
		<td><c:if test="${ empty id}">
			<input type="text" name="orgName" id="orgName" value="${orgName}" />
			<input type="hidden" name="orgCode" id="orgCode" value="${orgCode}" />
		</c:if> <c:if test="${ not empty id }">
			<input type="text" name="orgName" id="orgName"
				value="${branchOrgCode.organization.orgName}" disabled="disabled" />
			<input type="hidden" name="orgCode" id="orgCode" value="${orgCode}" />
		</c:if> <input type="hidden" name="id" id="id" value="${id}" /></td>
		<td>分支机构名称：</td>
		<td><input name="branchOrgCode" type="text"
			value="${branchOrgCode}" /> <input type="hidden" name="projectId"
			value="${projectId}" /> <input type="hidden" name="contractKind"
			value="${contractKind}" /></td>
	</tr>

	<tr>
		<td>合同名称：</td>
		<td><input name="contractOrder" type="text"
			value="${contractOrder}" /></td>
		<td>合同编号：</td>
		<td><input name="contractNum" type="text" value="${contractNum}" /></td>
	</tr>
	<tr>
		<td>起点桩号：</td>
		<td><input name="startPegNum" type="text" value="${startPegNum}" /></td>
		<td>终点桩号：</td>
		<td><input name="endPegNum" type="text" value="${endPegNum}" /></td>
	</tr>
	<tr>
		<td>开始时间：</td>
		<td><input id="beginDate" name="beginDate" type="text"
			value="${beginDate}" /></td>
		<td>结束时间：</td>
		<td><input id="endDate" name="endDate" type="text"
			value="${endDate}" /></td>
	</tr>
	<tr>
		<td>合同段造价(万元)：</td>
		<td><input name="contractCost" type="text"
			value="${contractCost}" /></td>
		<td>合同段主要内容：</td>
		<td><input name="contractContent" type="text"
			value="${contractContent}" /></td>
	</tr>
	<tr>
		<td>备注：</td>
		<td colspan="3"><input name="remark" type="text"
			value="${remark}" /></td>
	</tr>
</table>

</div>
<div class="type-button"><input id="addSuper"  
	type="submit" class="submit" value="提交" />&nbsp; <input
	  type="button" value="返回" class="reset"
	onclick="history.back()" /></div>
</form>
</body>
</html>
